#!/usr/bin/env python
# coding: utf-8

import web
from config import settings
from datetime import datetime

render = settings.render
db = settings.db
tb = 'user'

def get_by_id(id):
    s = db.select(tb, where='id=$id', vars=locals())
    if not s:
        return False
    return s[0]

# 判断邮件是否存在		
def get_email_exists(email):
	s = db.select(tb, where='email=$email', vars=locals())
	if not s:
		return False
	return True	

def get_user_exists(username):
	s=db.select(tb, where='name=$username', vars=locals())
	if not s:
		return False
	return True

class Reg:

    def GET(self):
        return render.user.reg()
	'''
		def POST(self, id):
        todo = get_by_id(id)
        if not todo:
            return render.error('没找到这条记录', None)
        i = web.input()
        title = i.get('title', None)
        if not title:
            return render.error('标题是必须的', None)
        db.update(tb, title=title, where='id=$id', vars=locals())
        return render.error('修改成功！', '/')
	'''
